package hcn.protocol.brandnew.dengji.guahao;

import com.fasterxml.jackson.annotation.JsonFormat;
import ctd.util.xml.jaxb.DateAdapter;
import ctd.util.xml.jaxb.DateTimeAdapter;
import hcn.protocol.brandnew.BaseRequest;
import lombok.Data;
import org.atag.sysrouter.annotation.DictionaryMapping;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.Date;
import java.util.List;


/**
 * 门诊挂号登记-消息请求(ODS_02030001) - ODS_02030001
 *
 * @author enjoyLife
 */
@Data
@XmlRootElement(name = "MsgBody")
@XmlAccessorType(XmlAccessType.FIELD)
public class AppointmentPayRequest extends BaseRequest {

    /**
     * 患者基本信息
     */
    @XmlElement(name = "Patient")
    private Patient patient;
    /**
     * 门（急）诊挂号记录
     */
    @XmlElement(name = "OptRegister")
    private OptRegister optRegister;

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class Patient {

        /**
         * 业务系统患者档案ID
         */
        @XmlElement(name = "SourcePatientId")
        private String sourcePatientId;
        /**
         * 业务系统患者档案类型
         */
        @XmlElement(name = "SourcePatientIdType")
        private String sourcePatientIdType;
        /**
         * 建档机构代码
         */
        @XmlElement(name = "AuthorOrganization")
        private String authorOrganization;
        /**
         * 身份证件号码
         */
        @XmlElement(name = "IdCard")
        private String idCard;
        /**
         * 身份证件类别代码
         */
        @XmlElement(name = "IdCardCode")
        private String idCardCode;
        /**
         * 患者姓名
         */
        @XmlElement(name = "Name")
        private String name;
        /**
         * 性别代码
         */
        @XmlElement(name = "Sex")
        private String sex;
        /**
         * 出生日期
         */
        @XmlElement(name = "BirthDate")
        @XmlJavaTypeAdapter(DateAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
        private Date birthDate;
        /**
         * 电话号码
         */
        @XmlElement(name = "PatientPhone")
        private String patientPhone;
        /**
         * 患者年龄
         */
        @XmlElement(name = "Age")
        private Short age;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class MedicalInsuranceCost {

        /**
         * 医保支付方式
         */
        @XmlElement(name = "MedicalInsuranceCostTypeCode")
        private Byte medicalInsuranceCostTypeCode;
        /**
         * 医保支付金额
         */
        @XmlElement(name = "MedicalInsuranceCost")
        private String medicalInsuranceCost;
    }

    @Data
    @XmlAccessorType(XmlAccessType.FIELD)
    public static class OptRegister {

        @XmlElement(name = "Force")
        private String force;
        /**
         * 挂号流水号
         */
        @XmlElement(name = "OutRegistryId")
        private String outRegistryId;
        /**
         * 患者类型代码
         */
        @XmlElement(name = "PatientType")
        private String patientType;
        /**
         * 门（急）诊号
         */
        @XmlElement(name = "ClinicId")
        private String clinicId;
        /**
         * 就诊次数
         */
        @XmlElement(name = "VisitTimes")
        private Long visitTimes;
        /**
         * 就诊卡类别代码
         */
        @XmlElement(name = "MedicalCardType")
        private String medicalCardType;
        /**
         * 就诊卡号
         */
        @XmlElement(name = "MedicalCardId")
        private String medicalCardId;
        /**
         * 挂号医师代码
         */
        @XmlElement(name = "RegisteredDcotor")
        private String registeredDcotor;
        /**
         * 挂号科室代码
         */
        @XmlElement(name = "RegisteredDept")
        private String registeredDept;
        /**
         * 就诊医疗机构组织机构代码
         */
        @XmlElement(name = "VisitOrganization")
        private String visitOrganization;
        /**
         * 就诊机构名称
         */
        @XmlElement(name = "VisitOrganizationName")
        private String visitOrganizationName;
        /**
         * 挂号类别代码
         */
        @XmlElement(name = "RegisteredType")
        private String registeredType;
        /**
         * 挂号日期时间
         */
        @XmlElement(name = "RegisteredDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date registeredDateTime;
        /**
         * 医师排班类别代码
         */
        @DictionaryMapping("hcn.base.dictionary.HCN_outpatientSchedulingService")
        @XmlElement(name = "DoctorDutyType")
        private String doctorDutyType;
        /**
         * 患者性质代码
         */
        @XmlElement(name = "PatientProperties")
        private String patientProperties;
        /**
         * 挂号顺序号
         */
        @XmlElement(name = "RegisteredSequence")
        private String registeredSequence;
        /**
         * 挂号单据号
         */
        @XmlElement(name = "RegisteredNo")
        private String registeredNo;
        /**
         * 诊查费
         */
        @XmlElement(name = "ExaminationCost")
        private String examinationCost;
        /**
         * 挂号费
         */
        @XmlElement(name = "RegisteredCost")
        private String registeredCost;
        /**
         * 专家费
         */
        @XmlElement(name = "DoctorCost")
        private String doctorCost;
        /**
         * 病历本费
         */
        @XmlElement(name = "BookCost")
        private String bookCost;
        /**
         * 就诊卡费
         */
        @XmlElement(name = "CardCost")
        private String cardCost;
        /**
         * 预约标志
         */
        @XmlElement(name = "IsAppoints")
        private String isAppoints;
        /**
         * 预约途径代码
         */
        @XmlElement(name = "AppointsRoute")
        private String appointsRoute;
        /**
         * 预约记录流水号
         */
        @XmlElement(name = "AppointsId")
        private String appointsId;
        /**
         * 挂号操作人
         */
        @XmlElement(name = "RegisterOperator")
        private String registerOperator;
        /**
         * 就诊原因
         */
        @XmlElement(name = "ClinicCause")
        private String clinicCause;
        /**
         * 医疗保险类别代码
         */
        @XmlElement(name = "MedicalInsuranceCategoryCode")
        private String medicalInsuranceCategoryCode;
        /**
         * 医疗保险类别名称
         */
        @XmlElement(name = "MedicalInsuranceName")
        private String medicalInsuranceName;
        /**
         * 挂号医师姓名
         */
        @XmlElement(name = "RegisteredDcotorName")
        private String registeredDcotorName;
        /**
         * 挂号科室名称
         */
        @XmlElement(name = "RegisteredDeptName")
        private String registeredDeptName;
        /**
         * 医生职称级别
         */
        @XmlElement(name = "DoctorMajorType")
        private String doctorMajorType;
        /**
         * 科室位置
         */
        @XmlElement(name = "DepartmentLocation")
        private String departmentLocation;
        /**
         * 资源池排班类型
         */
        @XmlElement(name = "OutpatientType")
        private Byte outpatientType;
        /**
         * 就诊流水号
         */
        @XmlElement(name = "VisitId")
        private String visitId;
        /**
         * 排班日期时间
         */
        @XmlElement(name = "ScheduleDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date scheduleDateTime;
        /**
         * 分时段开始时间
         */
        @XmlElement(name = "DaypartingBeginDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date daypartingBeginDateTime;
        /**
         * 分时段结束时间
         */
        @XmlElement(name = "DaypartingEndDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date daypartingEndDateTime;
        /**
         * 第三方交易流水号
         */
        @XmlElement(name = "AgtOrderNumber")
        private String agtOrderNumber;
        /**
         * 商户订单号
         */
        @XmlElement(name = "OutOrderNumber")
        private String outOrderNumber;
        /**
         * 医疗付费方式代码
         *
         * PayModeTransformUtil.hcnPayModeToHis
         */
        @DictionaryMapping("rmp.dic.medicalCostPayTypeCode")
        @XmlElement(name = "MedicalCostPayTypeCode")
        private String medicalCostPayTypeCode;
        /**
         * 结算日期时间
         */
        @XmlElement(name = "SettleDateTime")
        @XmlJavaTypeAdapter(DateTimeAdapter.class)
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
        private Date settleDateTime;
        /**
         * 挂号总金额
         */
        @XmlElement(name = "TotalCost")
        private String totalCost;
        /**
         * 自负金额
         */
        @XmlElement(name = "SelfCost")
        private String selfCost;
        /**
         * 医保报销总额
         */
        @XmlElement(name = "MedicalExpensesCost")
        private String medicalExpensesCost;
        /**
         * 医保支付方式集合
         */
        @XmlElementWrapper(name = "MedicalInsuranceCosts")
        @XmlElement(name = "MedicalInsuranceCost")
        private List<MedicalInsuranceCost> medicalInsuranceCosts;
        /**
         * 聚合支付交易流水号
         */
        @XmlElement(name = "ChannelOrderNumber")
        private String channelOrderNumber;
        /**
         * 是否进入队列
         */
        @XmlElement(name = "EnterQueue")
        private Byte enterQueue;
    }

}
